﻿<%@ Page Title="Manage Bindings" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ManageBindings.aspx.cs" Inherits="NIntegrate.Configuration.UI.ManageBindings" ValidateRequest="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2>Manage Bindings</h2>
    <div class="bottomhyperlink"><img alt="Add new binding" src="Images/plus.gif" /><asp:LinkButton 
            ID="btnShowAddNewPanel" runat="server" Text="Add new binding" 
            onclick="btnShowAddNewPanel_Click"></asp:LinkButton></div>
    <br />
    <asp:GridView CssClass="gridview"
        ID="gvBindings" runat="server" 
        DataSourceID="dsBindings"
        DataKeyNames="Binding_id"
        AllowSorting="true"
        AutoGenerateDeleteButton="true"
        AutoGenerateColumns="false"
        AutoGenerateEditButton="true" onrowcommand="gvBindings_RowCommand">
        <Columns>
            <asp:TemplateField HeaderText="BindingName" SortExpression="BindingName">
                <ItemTemplate>
                    <%#Eval("BindingName")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="tbBindingName" runat="server" MaxLength="100" Text='<%#Bind("BindingName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="tbBindingNameRequired" runat="server"
                        ControlToValidate="tbBindingName" EnableClientScript="false"
                        ErrorMessage="Required"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Type" SortExpression="BindingType_id">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlBindingTypes" runat="server" SelectedValue='<%# Bind("BindingType_id") %>' Enabled="false" DataTextField="BindingTypeFriendlyName" DataValueField="BindingType_id" DataSourceID="dsBindingTypes">
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlBindingTypes" runat="server" SelectedValue='<%# Bind("BindingType_id") %>' DataTextField="BindingTypeFriendlyName" DataValueField="BindingType_id" DataSourceID="dsBindingTypes">
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>                        
            <asp:TemplateField HeaderText="BindingXML" SortExpression="BindingXML">
                <ItemTemplate>
                    <%# Eval("BindingXML") == DBNull.Value ? string.Empty : Server.HtmlEncode((string)Eval("BindingXML"))%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="tbBindingXML" runat="server" Text='<%#Bind("BindingXML") %>' TextMode="MultiLine" Rows="3"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="tbBindingXMLRequired" runat="server"
                        ControlToValidate="tbBindingXML" EnableClientScript="false"
                        ErrorMessage="Required"></asp:RequiredFieldValidator>                    
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:CheckBoxField HeaderText="MexBindingEnabled" DataField="MexBindingEnabled" SortExpression="MexBindingEnabled" />
            <asp:CheckBoxField HeaderText="AddMexBindingOnly" DataField="AddMexBindingOnly" SortExpression="AddMexBindingOnly" />
        </Columns>
        <SelectedRowStyle BackColor="LightYellow" />
    </asp:GridView>
    <asp:Panel ID="panelBottom" runat="server" CssClass="panelBottom">
        <asp:DetailsView ID="dvAddBinding" runat="server" Visible="false"
            DataSourceID="dsBindings" DefaultMode="Insert"
            AutoGenerateRows="false"
            AutoGenerateInsertButton="true"
            CssClass="detailstable" onitemcommand="dvAddBinding_ItemCommand" 
            oniteminserted="dvAddBinding_ItemInserted">
            <HeaderTemplate>
                <h5>XML Templates:</h5>
                <a target="_blank" href="XmlTemplates/BasicHttpBinding.xml">BasicHttpBinding</a>
                <a target="_blank" href="XmlTemplates/MsmqIntegrationBinding.xml">MsmqIntegrationBinding</a>
                <a target="_blank" href="XmlTemplates/NetMsmqBinding.xml">NetMsmqBinding</a>
                <a target="_blank" href="XmlTemplates/NetNamedPipeBinding.xml">NetNamedPipeBinding</a>
                <a target="_blank" href="XmlTemplates/NetPeerTcpBinding.xml">NetPeerTcpBinding</a><br />
                <a target="_blank" href="XmlTemplates/NetTcpBinding.xml">NetTcpBinding</a>
                <a target="_blank" href="XmlTemplates/WSDualHttpBinding.xml">WSDualHttpBinding</a>
                <a target="_blank" href="XmlTemplates/WSFederationHttpBinding.xml">WSFederationHttpBinding</a>
                <a target="_blank" href="XmlTemplates/WSHttpBinding.xml">WSHttpBinding</a>
                <a target="_blank" href="XmlTemplates/CustomBinding.xml">CustomBinding</a>
            </HeaderTemplate>            
            <Fields>
                <asp:TemplateField HeaderText="BindingName">
                    <InsertItemTemplate>
                        <asp:TextBox ID="tbBindingName" runat="server" MaxLength="100" Text='<%#Bind("BindingName") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="tbBindingNameRequired" runat="server"
                            ControlToValidate="tbBindingName" EnableClientScript="false"
                            ErrorMessage="Required"></asp:RequiredFieldValidator>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Type">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlBindingTypes" runat="server" SelectedValue='<%# Bind("BindingType_id") %>' DataTextField="BindingTypeFriendlyName" DataValueField="BindingType_id" DataSourceID="dsBindingTypes">
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>                        
                <asp:TemplateField HeaderText="BindingXML">
                    <InsertItemTemplate>
                        <asp:TextBox ID="tbBindingXML" runat="server" Text='<%#Bind("BindingXML") %>' TextMode="MultiLine" Rows="3" Width="500px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="tbBindingXMLRequired" runat="server"
                            ControlToValidate="tbBindingXML" EnableClientScript="false"
                            ErrorMessage="Required"></asp:RequiredFieldValidator>                    
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:CheckBoxField HeaderText="MexBindingEnabled" DataField="MexBindingEnabled" />
                <asp:CheckBoxField HeaderText="AddMexBindingOnly" DataField="AddMexBindingOnly" />
            </Fields>
        </asp:DetailsView>
    </asp:Panel>
    <ni:QueryDataSource ID="dsBindings" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
    <ni:QueryDataSource ID="dsBindingTypes" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
</asp:Content>
